import commpackage.*;

public class TestComm {

	public static void main(String args[])
	{
		ConnectionType type = new ConnectionType();
		type.setHostname("localhost");
		type.setPort(3000);
		type.setSecurity(false);
		CommFactory fact = new CommFactory(); // This will no be called
		TestCallback cb = new TestCallback();

		System.out.println("Getting Comm Instance");
		Comm com = (Comm)fact.getCommInstance();

		System.out.println("Starting New Session");
		int session_id = com.newSession(cb, type);

		com.connect(session_id);
		System.out.println("Queueing Message");
		com.queueMessage(session_id, new String("Send this String Over!"));

		System.out.println("Reading Message");
		com.queueRead(session_id);
		while(cb.needStop() == false)
		{
			try
			{
				Thread.sleep(1000);
				System.out.println("Checking Thread!!!");
			}
			catch(Exception e)
			{
				System.out.println("Thread would not sleep!");
			}
		}
		com.disconnect(session_id);
	}
}
